// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

package
{
    import starling.display.Sprite;
    import starling.textures.TextureAtlas;
    import starling.utils.AssetManager;

    public class StarlingRootScene extends Sprite
    {
        private var mAssetManger:AssetManager;

        private var mScale9QuadBatch:Scale9QuadBatch;


        public function StarlingRootScene()
        {
            super();
            mAssetManger = new AssetManager();
            mAssetManger.enqueue("sprites.xml", "sprites.png");
            mAssetManger.loadQueue(function (_progress:Number):void
                                   {
                                       if (_progress == 1)
                                       {
                                           initialize();
                                       }

                                   });
        }

        private function initialize():void
        {
            var textureAtlas:TextureAtlas = mAssetManger.getTextureAtlas("sprites");


            mScale9QuadBatch = new Scale9QuadBatch(150, 250,
                                                   textureAtlas.getTexture("topLeft.png"),
                                                   textureAtlas.getTexture("topRight.png"),
                                                   textureAtlas.getTexture("bottomLeft.png"),
                                                   textureAtlas.getTexture("bottomRight.png"),
                                                   textureAtlas.getTexture("middle.png"),
                                                   textureAtlas.getTexture("topMiddle.png"),
                                                   textureAtlas.getTexture("leftMiddle.png"),
                                                   textureAtlas.getTexture("rightMiddle.png"),
                                                   textureAtlas.getTexture("bottomMiddle.png"));
            addChild(mScale9QuadBatch);
            mScale9QuadBatch.x = mScale9QuadBatch.y = 50;
        }

    }
}
